//reducer 函数以及对应的 action 函数
export default function zanReducer(init=5, action){
  switch(action.type){
    //action.type 的值在 redux 中是唯一的, 不能重复
    case 'jia':
      return init + action.payload;
    case 'jian':
      return init - action.payload;
    default:
      return init;
  }
} 

// jiaAction(10)  => {type: 'jia', payload: 10}
export function jiaAction(payload){
  return {
    type: 'jia',
    payload: payload
  }
}

export function jianAction(payload){
  return {
    type: 'jian',
    payload: payload
  }
}